﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Networking;

public class Character : Entity
{
    [CompilerGenerated]
    private static Action<Character> <>f__am$cacheC;
    [CompilerGenerated]
    private static Action<Character> <>f__am$cacheD;
    public static List<Character> all = new List<Character>();
    private Attack m_attack;
    private Collider m_co;
    private Dodge m_dodge;
    private Interact m_interact;
    private Inventory m_inventory;
    private Life m_life;
    private Look m_look;
    private Move m_move;
    private Rigidbody m_rb;
    public static Action<Character> onAnyCreate;
    public static Action<Character> onAnyDestroy;

    static Character()
    {
        if (<>f__am$cacheC == null)
        {
            <>f__am$cacheC = new Action<Character>(Character.<onAnyCreate>m__4B);
        }
        onAnyCreate = <>f__am$cacheC;
        if (<>f__am$cacheD == null)
        {
            <>f__am$cacheD = new Action<Character>(Character.<onAnyDestroy>m__4C);
        }
        onAnyDestroy = <>f__am$cacheD;
    }

    [CompilerGenerated]
    private static void <onAnyCreate>m__4B(Character c)
    {
    }

    [CompilerGenerated]
    private static void <onAnyDestroy>m__4C(Character c)
    {
    }

    protected override void Awake()
    {
        base.Awake();
        base.gameObject.layer = GameLayers.Character.index;
        onAnyCreate(this);
        all.Add(this);
    }

    public void DestroyItem(Item item)
    {
        if (this.inventory != null)
        {
            this.inventory.DestroyItem(item);
        }
    }

    public Item GainItem(string itemName)
    {
        if (this.inventory != null)
        {
            return this.inventory.GainItem(itemName);
        }
        return null;
    }

    public int GetConsumableAmount(string itemName)
    {
        return ((this.inventory == null) ? 0 : this.inventory.GetConsumableAmount(itemName));
    }

    public bool HasEnergy(float value)
    {
        return ((this.attack != null) && this.attack.HasEnergy(value));
    }

    public void IncreaseConsumableAmount(string itemName, int amount)
    {
        if (this.inventory != null)
        {
            this.inventory.IncreaseConsumableAmount(itemName, amount);
        }
    }

    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        base.OnDeserialize(reader, initialState);
    }

    protected override void OnDestroy()
    {
        base.OnDestroy();
        onAnyDestroy(this);
        all.Remove(this);
    }

    public override bool OnSerialize(NetworkWriter writer, bool forceAll)
    {
        bool flag;
        bool flag2 = base.OnSerialize(writer, forceAll);
        return (flag | flag2);
    }

    public void PickupItem(Item item)
    {
        if (this.inventory != null)
        {
            this.inventory.Pickup(item);
        }
    }

    public void Resurrect()
    {
        if (this.life != null)
        {
            this.life.Resurrect();
        }
    }

    public void SetConsumableAmount(string itemName, int amount)
    {
        if (this.inventory != null)
        {
            this.inventory.SetConsumableAmount(itemName, amount);
        }
    }

    private void UNetVersion()
    {
    }

    public Attack attack
    {
        get
        {
            if (this.m_attack == null)
            {
            }
            return (this.m_attack = base.GetComponent<Attack>());
        }
    }

    public Collider co
    {
        get
        {
            if (this.m_co == null)
            {
            }
            return (this.m_co = base.GetComponent<Collider>());
        }
    }

    public Dodge dodge
    {
        get
        {
            if (this.m_dodge == null)
            {
            }
            return (this.m_dodge = base.GetComponent<Dodge>());
        }
    }

    public float energy
    {
        get
        {
            return ((this.attack == null) ? 0f : this.attack.energy);
        }
        set
        {
            if (this.attack != null)
            {
                this.attack.energy = value;
            }
        }
    }

    public Interact interact
    {
        get
        {
            if (this.m_interact == null)
            {
            }
            return (this.m_interact = base.GetComponent<Interact>());
        }
    }

    public Inventory inventory
    {
        get
        {
            if (this.m_inventory == null)
            {
            }
            return (this.m_inventory = base.GetComponent<Inventory>());
        }
    }

    public bool isDied
    {
        get
        {
            return ((this.life == null) || this.life.isDied);
        }
    }

    public bool isInfinteEnergy
    {
        get
        {
            return ((this.attack != null) && this.attack.isInfinteEnergy);
        }
        set
        {
            if (this.attack != null)
            {
                this.attack.isInfinteEnergy = value;
            }
        }
    }

    public Life life
    {
        get
        {
            if (this.m_life == null)
            {
            }
            return (this.m_life = base.GetComponent<Life>());
        }
    }

    public Look look
    {
        get
        {
            if (this.m_look == null)
            {
            }
            return (this.m_look = base.GetComponent<Look>());
        }
    }

    public float maxEnergy
    {
        get
        {
            return ((this.attack == null) ? 0f : this.attack.maxEnergy);
        }
        set
        {
            if (this.attack != null)
            {
                this.attack.maxEnergy = value;
            }
        }
    }

    public int money
    {
        get
        {
            return ((this.inventory == null) ? 0 : this.inventory.money);
        }
        set
        {
            if (this.inventory != null)
            {
                this.inventory.money = value;
            }
        }
    }

    public Move move
    {
        get
        {
            if (this.m_move == null)
            {
            }
            return (this.m_move = base.GetComponent<Move>());
        }
    }

    public Vector3 position
    {
        get
        {
            return base.transform.position;
        }
        set
        {
            base.transform.position = value;
        }
    }

    public Rigidbody rb
    {
        get
        {
            if (this.m_rb == null)
            {
            }
            return (this.m_rb = base.GetComponent<Rigidbody>());
        }
    }

    public Weapon secondWeapon
    {
        get
        {
            return ((this.inventory == null) ? null : this.inventory.secondWeapon);
        }
    }

    public Suit suit
    {
        get
        {
            return ((this.inventory == null) ? null : this.inventory.suit);
        }
    }

    public Weapon weapon
    {
        get
        {
            return ((this.inventory == null) ? null : this.inventory.weapon);
        }
    }
}

